#include"threadPool.h"
#include"thread.h"

    ThreadPool::ThreadPool(int number):numberOfThread(number)
    {
        for(int i=0;i<numberOfThread;++i)
        {
            m_pool.push_back(new Thread());
        }
    }
    ThreadPool::~ThreadPool()
    {
        for(int i=numberOfThread-1;i>=0;--i)
        {
            delete m_pool[i];
            m_pool.pop_back();
        }
    }
    int ThreadPool::GetNumberOfThread()const
    {
        return numberOfThread;
    }

    int ThreadPool::GetSubThreadSocketPairFirst()const//负载均衡，轮询算法
    {
        static int robin=0;
        return m_pool[robin++ % numberOfThread]->GetSocketPairFirst();
    }